<!DOCTYPE html>
<html lang="zh-CN">
<head>
<title>文件检测</title>
<link rel="stylesheet" type="text/css" href="__static__/layui/css/layui.css" media="all">
<script type="text/javascript" src="__static__/js/jquery-1.11.2.min.js"></script>
<!-- <script type="text/javascript" src="__static__/layui/lay/modules/layer.js"></script> -->
<script type="text/javascript" src="__static__/layer/layer.js"></script>
<style type="text/css">
.layui-table th,td{text-align: center;}
</style>
</head>
<body>

<div style="margin: 0 auto; width: 90%;">
    <a href="{:url('Index/get_files')}" class="layui-btn">获取文件</a>
    <a href="{:url('Index/index',['px'=>0])}" class="layui-btn">默认排序</a>
    <a href="{:url('Index/index',['px'=>1])}" class="layui-btn">创建时间排序</a>
    <a href="{:url('Index/index',['px'=>2])}" class="layui-btn">修改时间排序</a>
	<a href="{:url('Index/index',['px'=>3])}" class="layui-btn">获取时间排序</a>
	<form id="export-form" method="post" action="{:url('Index/export')}">
	<table class="layui-table">
	    <thead>
	      <tr>
	        <th width="50"><input class="check-all filled-in" checked="chedked" type="checkbox" value=""></th>
	        <th width="50">序号</th>
	        <th>名称</th>
	        <th>文件大小</th>
	        <th>创建时间</th>
            <th>修改时间</th>
	        <th>获取时间</th>
	        <th>详情</th>
	      </tr> 
	    </thead>
		<tbody>
	   {volist name='list' id='row' key="k"}   
	    <tr>
	        <td><input class="ids" type="checkbox" checked="chedked" name="tables[]" value="{$row['id']}"></td>
	        <td>{$k}</td>
	        <td id="title{$row['id']}" style="text-align: left;" onclick="view({$row['id']})">{$row['title']}</td>
	        <td>{$row['filesize']|format_bytes}</td>
            <td>{$row['filectime']|date='Y-m-d H:i:s',###}</td>
            <td>{$row['filemtime']|date='Y-m-d H:i:s',###}</td>
	        <td>{$row['addtime']|date='Y-m-d H:i:s',###}</td>
	        <td>
	        	<a onclick="view({$row['id']})">详情</a>
	        </td>
	    </tr>
	    {/volist}
	    </tbody>
	</table>
	</form>
</div>

<script>
$('.check-all').on('click', function(){
    var this_checked = false;
    if ($(this).prop("checked")) {
        this_checked = true;
    }
    $(".ids").each(function(index){
      if (this_checked) {
          $(this).prop("checked",true);
      }else{
          $(this).prop("checked",false);
      }
    });
});

function view(id){
	var title = $('#title'+id).html();
	console.log(title);
	var index = layer.open({
		type: 2,
        title: title,
        closeBtn: true, //不显示关闭按钮
        area: ['893px', '600px'],
        shadeClose: true, //开启遮罩关闭
		content: '{:url("Index/view")}?id='+id,
	});
}
</script>
</body>
</html>

